package com.uplift.mgt.product.service.impl;

import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.uplift.common.utils.UUIDGenerater;
import com.uplift.mgt.product.dao.IOrderMapper;
import com.uplift.mgt.product.model.Order;
import com.uplift.mgt.product.service.IOrderService;
import com.uplift.sec.SecurityContext;

@Service
@Transactional
public class OrderServiceImpl implements IOrderService {

	@Autowired
	private IOrderMapper orderMapper;

	@Override
	public List<Map<String, Object>> queryOrder(Order order) {
		return this.orderMapper.selectOrder(order);
	}

	@Override
	public int saveOrder(Order order) {
		order.setId(UUIDGenerater.generate());
		return this.orderMapper.insertOrder(order);
	}

	@Override
	public int modifyOrder(Order order) {
		order.setOpUserId(Objects.toString(SecurityContext.getSessionUser().get("id")));
		return this.orderMapper.updateOrder(order);
	}
	
	@Override
	public int removeOrder(Order order) {
		return this.orderMapper.deleteOrder(order);
	}

}
